Skip to content

Conversation

@Jenson3210
Copy link
Contributor

@Jenson3210 Jenson3210 commented Sep 23, 2025

Added some preconditional approach to the oldValue using regexes.

I am not sure though if this change is worth the "win" of not seeing the change happening.

Before this PR,

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
          https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
         version="6.0">
    <display-name>Unit testing</display-name>
</web-fragment>

Would be migrated to

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
         version="5.0">
    <display-name>Unit testing</display-name>
</web-fragment>

to than later be migrated back to version 6. (notice the newline diff resulting in the end causing unneeded reviewable change)

@Jenson3210 Jenson3210 self-assigned this Sep 23, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Sep 23, 2025
@Jenson3210
Copy link
Contributor Author

@timtebeek As I mentioned above: not sure if we would even want this change. Introducing a bit "heavier" oldValue regex checks just for this purpose seems odd, no?

Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's tolerable to have this change. optionally with a little less stringent prefix pattern on that particular faces 4 recipe.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Sep 23, 2025
attributeName: xsi:schemaLocation
elementName: web-app
newValue: https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd
oldValue: (?<prefix>https://jakarta\.ee/xml/ns/jakartaee\s+https://jakarta\.ee/xml/ns/jakartaee/web-app_)5_\d+(?<extension>\.xsd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where I wonder if for clarity (and less chance of mismatches) we can use a simpler pattern of replacements.

Suggested change
oldValue: (?<prefix>https://jakarta\.ee/xml/ns/jakartaee\s+https://jakarta\.ee/xml/ns/jakartaee/web-app_)5_\d+(?<extension>\.xsd)
oldValue: (?<prefix>.*https://jakarta\.ee/xml/ns/jakartaee/web-app_)5_\d+(?<extension>\.xsd)

attributeName: xsi:schemaLocation
elementName: web-app
newValue: https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd
oldValue: (?<prefix>[\S\s]*https://jakarta\.ee/xml/ns/jakartaee/web-app_)5_\d+(?<suffix>\.xsd[\S\s]*)
Copy link
Member

@timtebeek timtebeek Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A character group of [\S\s] would just mean anything right? Then .* feels more intuitive.

\s	A whitespace character: [ \t\n\x0B\f\r]
\S	A non-whitespace character: [^\s]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.* does not match on \n where \s\S will match on these newline variations also. I did not get it to work with .* and the added unit test/newlines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah guess that would require a multiline flag to be added; in that case we can go with this option, or prefix the regex with (?m) to make it explicit that we tolerate multilines as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the multiline, I indeed also tried.

That would work if we do not expect the entire string to match. That matches the line (so as of the newline) that matches the string, not the entire value.
I did find that the dotall flag does match the entire surrounding values.
Screenshot 2025-09-25 at 01 32 52
Screenshot 2025-09-25 at 01 32 46

@timtebeek
Copy link
Member

Any reason you'd held off on a merge here @Jenson3210 ?

@Jenson3210 Jenson3210 merged commit 2fd7b1b into main Sep 30, 2025
2 checks passed
@Jenson3210 Jenson3210 deleted the fix-whiteline-introduced branch September 30, 2025 21:31
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Sep 30, 2025
@Jenson3210
Copy link
Contributor Author

Nope 🫣

mergify bot added a commit to robfrank/linklift that referenced this pull request Oct 15, 2025
…18.0 to 3.19.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 3.18.0 to 3.19.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-migrate-java's releases](https://github.com/openrewrite/rewrite-migrate-java/releases).*

> 3.19.0
> ------
>
> What's Changed
> --------------
>
> * Fixing SDKMan tests by [`@​steve-aom-elliott`](https://github.com/steve-aom-elliott) in [openrewrite/rewrite-migrate-java#858](https://github.com/openrewrite/rewrite-migrate-java/pull/858)
> * Adopt `Style.from` instead of `SourceFile.getStyle` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#859](https://github.com/openrewrite/rewrite-migrate-java/pull/859)
> * Fixed the whiteline removal for the schemaLocations when already properly migrated by [`@​Jenson3210`](https://github.com/Jenson3210) in [openrewrite/rewrite-migrate-java#855](https://github.com/openrewrite/rewrite-migrate-java/pull/855)
> * OpenRewrite recipe best practices by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#860](https://github.com/openrewrite/rewrite-migrate-java/pull/860)
> * Update recipe documentation examples by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#864](https://github.com/openrewrite/rewrite-migrate-java/pull/864)
> * Fix UseVarForGenericMethodInvocations for nested generics with diamond operators by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#863](https://github.com/openrewrite/rewrite-migrate-java/pull/863)
> * Update documentation examples by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#865](https://github.com/openrewrite/rewrite-migrate-java/pull/865)
> * Add explicit type arguments to generic methods in `UseVarForGenericMethodInvocations` by [`@​jagodevreede`](https://github.com/jagodevreede) in [openrewrite/rewrite-migrate-java#869](https://github.com/openrewrite/rewrite-migrate-java/pull/869)
> * Don't replace instance methods accessing static fields by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#871](https://github.com/openrewrite/rewrite-migrate-java/pull/871)
>
> New Contributors
> ----------------
>
> * [`@​jagodevreede`](https://github.com/jagodevreede) made their first contribution in [openrewrite/rewrite-migrate-java#869](https://github.com/openrewrite/rewrite-migrate-java/pull/869)
>
> **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.18.0...v3.19.0>


Commits

* [`da6ad68`](openrewrite/rewrite-migrate-java@da6ad68) Don't replace instance methods accessing static fields ([#871](https://github.com/openrewrite/rewrite-migrate-java/issues/871))
* [`357191e`](openrewrite/rewrite-migrate-java@357191e) Add explicit type arguments to generic methods in `UseVarForGenericMethodInvo...
* [`45e12e2`](openrewrite/rewrite-migrate-java@45e12e2) [Auto] SDKMAN! Java candidates as of 2025-10-06T1015
* [`c89ae45`](openrewrite/rewrite-migrate-java@c89ae45) Update documentation examples ([#865](https://github.com/openrewrite/rewrite-migrate-java/issues/865))
* [`c1ac90b`](openrewrite/rewrite-migrate-java@c1ac90b) Fix UseVarForGenericMethodInvocations for nested generics with diamond operat...
* [`9092d22`](openrewrite/rewrite-migrate-java@9092d22) Update recipe documentation examples ([#864](https://github.com/openrewrite/rewrite-migrate-java/issues/864))
* [`640ac12`](openrewrite/rewrite-migrate-java@640ac12) OpenRewrite recipe best practices ([#860](https://github.com/openrewrite/rewrite-migrate-java/issues/860))
* [`2fd7b1b`](openrewrite/rewrite-migrate-java@2fd7b1b) Fixed the whiteline removal for the schemaLocations when already properly mig...
* [`75b6048`](openrewrite/rewrite-migrate-java@75b6048) Adopt `Style.from` instead of `SourceFile.getStyle` ([#859](https://github.com/openrewrite/rewrite-migrate-java/issues/859))
* [`7082b93`](openrewrite/rewrite-migrate-java@7082b93) Fixing SDKMan tests ([#858](https://github.com/openrewrite/rewrite-migrate-java/issues/858))
* Additional commits viewable in [compare view](openrewrite/rewrite-migrate-java@v3.18.0...v3.19.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-migrate-java&package-manager=maven&previous-version=3.18.0&new-version=3.19.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants